package com.itheima;

import java.util.HashMap;
import java.util.Scanner;

public class Demo5 {
    public static void main(String[] args) {
        String str = "wo ai heima wo ai java wo yao hao hao xue xi java";
        String[] arr = str.split(" +");

        HashMap<String, Integer> map = new HashMap<>();
        for (String s: arr) {
            map.put(s, map.containsKey(s) ? map.get(s) + 1 : 1);
        }
        for (String key: map.keySet()) {
            System.out.println(key + "(" + map.get(key) + ")");
        }
    }
}
